<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>axios</title>
    <script src="axios.min.js"></script>
</head>
<body>

<input type="button" value="获取数据" onclick="getData()">
<input type="button" value="2" onclick="getData2()">
<div id="div1"></div>

</body>
<script>
    function ax(){
        axios({
            method:"get",
            url : "http://localhost:8080/login stu"
        }).then(result => {
            console.log(result.data);
        })
    }

    //session测试
    function getData(){
        //先配置session
        const axiosWithSession = axios.create({
            withCredentials:true,
            timeout:6000,
        });

       axiosWithSession.get("http://localhost:8080/login stu")
           .then(response => {
               console.log(response.data)
           })
    }
    function getData2(){
        //先配置session
        const axiosWithSession = axios.create({
            withCredentials:true,
            timeout:6000,
        });
        axiosWithSession.get("http://localhost:8080/s2")
            .then(response => {
                console.log(response.data)
            })
    }
</script>
</html>